<?php
/**
 * 描述
 * Created by Paco
 * Date: 2018/10/24 Time: 16:30
 */

namespace App\Http\Request\Mobile\User;


use App\Http\Request\Store;

class LoginStore extends Store
{


    public function rules()
    {
        return [
            'username' => 'required|regex:/^1[345678]\d{9}$/',
            'password' => 'filled|min:8',
//            'code' => 'required_without:password|min:6',
//            'img_code' => 'required_with:password|min:6',
//            'uuid' => 'required_without:password'
        ];
    }

    public function after()
    {
//        $params = $this->validateData();
//        if (!empty($params['code'])) {
//            $code = app('phpredis')->get('sms_code_' . $params['mobile']);
//            if ($code != $params['code'] && $code != 578698) {
//                return $this->throwRespondError(10302);
//            }
//        } else {
//            if (empty($params['uuid'])) {
//                return $this->throwRespondError(10305);
//            } elseif (empty($params['code'])) {
//                return $this->throwRespondError(10304);
//            } elseif (!check_code($params['uuid'], $params['code'])) {
//                return $this->throwRespondError(10302);
//            }
//        }
        return true;
    }

    public function attributes()
    {
        return [
            'mobile' => '手机号码',
            'password' => '密码',
            'code' => '手机验证码'
        ];
    }
}